<?php


namespace App\Model\Repository;


use App\Model\Base\ApiResponseBody;
use Michelf\Markdown;

/**
 * Class ApiResponseBodyRepository
 * @package App\Model\Repository
 */
class ApiResponseBodyRepository extends ApiResponseBody
{
    public function api()
    {
        return $this->belongsTo(ApiRepository::class, 'api_id', 'api_id');
    }

    /**
     * 返回body字段的html格式代码
     */
    public function getBodyHtml()
    {
        return Markdown::defaultTransform($this->getBody());
    }

    /**
     * 返回demo字段的html格式代码
     */
    public function getDemoHtml()
    {
        return Markdown::defaultTransform($this->getDemo());
    }
}